package com.jcraft.jsch;

import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum SshMsgEnum {
    SSH_MSG_DISCONNECT(1, "SSH_MSG_DISCONNECT"),
    SSH_MSG_IGNORE(2, "SSH_MSG_IGNORE"),
    SSH_MSG_UNIMPLEMENTED(3, "SSH_MSG_UNIMPLEMENTED"),
    SSH_MSG_DEBUG(4, "SSH_MSG_DEBUG"),
    SSH_MSG_SERVICE_REQUEST(5, "SSH_MSG_SERVICE_REQUEST"),
    SSH_MSG_SERVICE_ACCEPT(6, "SSH_MSG_SERVICE_ACCEPT"),
    SSH_MSG_KEXINIT(20, "SSH_MSG_KEXINIT"),
    SSH_MSG_NEWKEYS(21, "SSH_MSG_NEWKEYS"),
    SSH_MSG_KEXDH_INIT(30, "SSH_MSG_KEXDH_INIT"),
    SSH_MSG_KEXDH_REPLY(31, "SSH_MSG_KEXDH_REPLY"),
    //    SSH_MSG_KEX_DH_GEX_GROUP(31, "SSH_MSG_KEX_DH_GEX_GROUP"),
    SSH_MSG_KEX_DH_GEX_INIT(32, "SSH_MSG_KEX_DH_GEX_INIT"),
    SSH_MSG_KEX_DH_GEX_REPLY(33, "SSH_MSG_KEX_DH_GEX_REPLY"),
    SSH_MSG_KEX_DH_GEX_REQUEST(34, "SSH_MSG_KEX_DH_GEX_REQUEST"),
    SSH_MSG_GLOBAL_REQUEST(80, "SSH_MSG_GLOBAL_REQUEST"),
    SSH_MSG_REQUEST_SUCCESS(81, "SSH_MSG_REQUEST_SUCCESS"),
    SSH_MSG_REQUEST_FAILURE(82, "SSH_MSG_REQUEST_FAILURE"),
    SSH_MSG_CHANNEL_OPEN(90, "SSH_MSG_CHANNEL_OPEN"),
    SSH_MSG_CHANNEL_OPEN_CONFIRMATION(91, "SSH_MSG_CHANNEL_OPEN_CONFIRMATION"),
    SSH_MSG_CHANNEL_OPEN_FAILURE(92, "SSH_MSG_CHANNEL_OPEN_FAILURE"),
    SSH_MSG_CHANNEL_WINDOW_ADJUST(93, "SSH_MSG_CHANNEL_WINDOW_ADJUST"),
    SSH_MSG_CHANNEL_DATA(94, "SSH_MSG_CHANNEL_DATA"),
    SSH_MSG_CHANNEL_EXTENDED_DATA(95, "SSH_MSG_CHANNEL_EXTENDED_DATA"),
    SSH_MSG_CHANNEL_EOF(96, "SSH_MSG_CHANNEL_EOF"),
    SSH_MSG_CHANNEL_CLOSE(97, "SSH_MSG_CHANNEL_CLOSE"),
    SSH_MSG_CHANNEL_REQUEST(98, "SSH_MSG_CHANNEL_REQUEST"),
    SSH_MSG_CHANNEL_SUCCESS(99, "SSH_MSG_CHANNEL_SUCCESS"),
    SSH_MSG_CHANNEL_FAILURE(100, "SSH_MSG_CHANNEL_FAILURE"),
    ;
    private int code;
    private String message;

    public static final SshMsgEnum getByCode(int code) {
        for (SshMsgEnum tmpEnum : values()) {
            if (tmpEnum.getCode() == code) {
                return tmpEnum;
            }
        }
        return null;
    }
}
